<template>
	<view class="mock">
		<view class="kda" v-for="(v,i) in data.title" :key="i" @click="clickit(i)" :class="{active:active==i}">
			{{v}}
		</view>
	</view>
</template>

<script>
	import {mapState,mapGetters,mapMutations} from 'vuex'
	export default {
		name:"cartList",
		data() {
			return {
				data:{
					title:['当期爆品','往期爆品','公交地铁卡','积分商城','联系客服'],	
				}
			};
		},
		computed:{
			active(){
				return this.$store.state.m_cart.active
			}
		},
		methods:{
			clickit(i){
				console.log(this.$store);
				// 点击按钮,给index+1
				// this.active = i
				this.$store.commit('m_cart/dj',i)
			}
		}
	}
</script>

<style>
.kda{
	width: 100px;
	height: 50px;
	line-height: 50px;
	
	text-align: center;
}
.mock{
	border-bottom: solid gray 1px;
}
.active{
	color: red;
	background-color: aliceblue;
}
</style>